<!doctype html>
<html>

<head>
    <meta charset="utf-8">
    <title>微博</title>
    <link href="style/weibo.css" rel="stylesheet" type="text/css" />
    <script src="lib/react.development.js"></script>
    <script src="lib/react-dom.development.js"></script>
    <script src="lib/babel.min.js"></script>
    <script src="./node_modules/axios/dist/axios.min.js"></script>

    <script type="text/babel" src="./components/TakeComment.jsx"></script>
    <script type="text/babel" src="./components/CommentOn.jsx"></script>
    <script type="text/babel" src="./components/PageList.jsx"></script>
    <script type="text/babel" src="./components/App.jsx"></script>
</head>

<body>
    <div class="jyArea">

    </div>
</body>
<script type="text/babel">
    // 1.创建axios请求
    const request = axios.create({
        baseURL: 'http://localhost:8081'
    })
    // 2.响应拦截器，做数据处理和响应失败的处理
    request.interceptors.response.use((res) => {
        // 2.1 解构赋值获取响应的数据ok和msg
        const { ok, msg } = res.data
        // 2.2 通过ok判断如果请求失败就提示错误信息,否则就返回响应数据
        if (ok === -1) {
            alert(msg)
            // 2.3 请求失败返回一个等待状态的promise，停止后续操作
            return new Promise(() => { })
        }
        return res.data
    })

    ReactDOM.createRoot(document.querySelector(".jyArea")).render(<App />)
</script>

</html>